Skip to content

perf(docker): replace subprocess spawning with Docker Engine HTTP API#44

Merged
IamShobe merged 1 commit into
mainfrom
perf/docker-adapter-api
Mar 20, 2026
Merged

perf(docker): replace subprocess spawning with Docker Engine HTTP API#44
IamShobe merged 1 commit into
mainfrom
perf/docker-adapter-api

Conversation

@IamShobe

Copy link
Copy Markdown
Owner

Summary

  • Replace child_process.spawn calls with dockerode (Docker Engine HTTP API via unix socket), eliminating ~100-200ms of process fork/exec overhead per container per query
  • Fix line buffering bug: data.split(/(\r?\n)/g) used a capturing group and had no cross-chunk buffer, silently dropping log lines that spanned pipe chunk boundaries
  • Pre-compile log pattern regexes in the constructor instead of new RegExp() on every log line
  • Deliver incremental results via onBatchDone as each container completes, instead of waiting for all containers to finish
  • Remove noisy console.log/console.warn calls from hot paths

BREAKING: binaryLocation param removed — the adapter now talks directly to the Docker Engine API via dockerHost instead of shelling out to the docker CLI binary.

Test plan

  • lint / format / tests / typecheck all pass (CI)
  • Query with multiple containers: confirm logs are returned correctly
  • Verify no log lines are missing compared to previous implementation
  • Confirm partial results appear in the UI as each container finishes

Switch from shelling out to the `docker` CLI binary to using dockerode,
which communicates directly with the Docker socket. This eliminates
per-query process fork/exec overhead (~100-200ms per container).

Other improvements:
- Fix line buffering: properly handle log lines spanning chunk boundaries
- Pre-compile log pattern regexes in the constructor instead of per-line
- Deliver incremental results as each container completes (onBatchDone)
- Remove noisy console.log/warn calls from hot paths

BREAKING: `binaryLocation` param removed — no longer needed since the
adapter talks directly to the Docker Engine API via `dockerHost`.
@IamShobe
IamShobe merged commit 7bc9cd6 into main Mar 20, 2026
4 checks passed
@IamShobe
IamShobe deleted the perf/docker-adapter-api branch March 20, 2026 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant